<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>esapi.codecs.codec.Codec</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  <script type="text/javascript" src="epydoc.js"></script>
</head>

<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="esapi-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

      <th class="navbar" width="100%"></th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <span class="breadcrumbs">
        esapi ::
        codecs ::
        codec ::
        Codec ::
        Class&nbsp;Codec
      </span>
    </td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <!-- hide/show private -->
        <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
    onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr>
        <tr><td align="right"><span class="options"
            >[<a href="frames.html" target="_top">frames</a
            >]&nbsp;|&nbsp;<a href="esapi.codecs.codec.Codec-class.html"
            target="_top">no&nbsp;frames</a>]</span></td></tr>
      </table>
    </td>
  </tr>
</table>
<!-- ==================== CLASS DESCRIPTION ==================== -->
<h1 class="epydoc">Class Codec</h1><p class="nomargin-top"><span class="codelink"><a href="esapi.codecs.codec-pysrc.html#Codec">source&nbsp;code</a></span></p>
<dl><dt>Known Subclasses:</dt>
<dd>
      <ul class="subclass-list">
<li><a href="esapi.codecs.mysql.MySQLCodec-class.html">mysql.MySQLCodec</a></li><li>, <a href="esapi.codecs.windows.WindowsCodec-class.html">windows.WindowsCodec</a></li><li>, <a href="esapi.codecs.vbscript.VBScriptCodec-class.html">vbscript.VBScriptCodec</a></li><li>, <a href="esapi.codecs.ldap.LDAPCodec-class.html">ldap.LDAPCodec</a></li><li>, <a href="esapi.codecs.oracle.OracleCodec-class.html">oracle.OracleCodec</a></li><li>, <a href="esapi.codecs.css.CSSCodec-class.html">css.CSSCodec</a></li><li>, <a href="esapi.codecs.html_entity.HTMLEntityCodec-class.html">html_entity.HTMLEntityCodec</a></li><li>, <a href="esapi.codecs.unix.UnixCodec-class.html">unix.UnixCodec</a></li><li>, <a href="esapi.codecs.percent.PercentCodec-class.html">percent.PercentCodec</a></li><li>, <a href="esapi.codecs.javascript.JavascriptCodec-class.html">javascript.JavascriptCodec</a></li><li>, <a href="esapi.codecs.ldap_dn.LDAPDNCodec-class.html">ldap_dn.LDAPDNCodec</a></li>  </ul>
</dd></dl>

<hr />
<p>The Codec interface defines a set of methods for encoding and decoding
  application level encoding schemes, such as HTML entity encoding and 
  percent encoding (aka URL encoding). Codecs are used in output encoding 
  and canonicalization.  The design of these codecs allows for 
  character-by-character decoding, which is necessary to detect 
  double-encoding and the use of multiple encoding schemes, both of which 
  are techniques used by attackers to bypass validation and bury encoded 
  attacks in data.</p>

<hr />
<div class="fields">      <p><strong>Author:</strong>
        Craig Younkins (craig.younkins@owasp.org)
      </p>
      <p><strong>See Also:</strong>
        <a href="esapi.encoder-module.html" class="link">esapi.encoder</a>
      </p>
</div><!-- ==================== INSTANCE METHODS ==================== -->
<a name="section-InstanceMethods"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Instance Methods</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-InstanceMethods"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="__init__"></a><span class="summary-sig-name">__init__</span>(<span class="summary-sig-arg">self</span>)</span></td>
          <td align="right" valign="top">
            <span class="codelink"><a href="esapi.codecs.codec-pysrc.html#Codec.__init__">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="esapi.codecs.codec.Codec-class.html#encode" class="summary-sig-name">encode</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">immune</span>,
        <span class="summary-sig-arg">raw</span>)</span><br />
      Encode a String so that it can be safely used in a specific context.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="esapi.codecs.codec-pysrc.html#Codec.encode">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="esapi.codecs.codec.Codec-class.html#encode_character" class="summary-sig-name">encode_character</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">immune</span>,
        <span class="summary-sig-arg">char</span>)</span><br />
      Default implementation that should be overridden in specific codecs.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="esapi.codecs.codec-pysrc.html#Codec.encode_character">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="esapi.codecs.codec.Codec-class.html#decode" class="summary-sig-name">decode</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">encoded</span>)</span><br />
      Decode a String that was encoded using the encode method in this 
      Class</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="esapi.codecs.codec-pysrc.html#Codec.decode">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="esapi.codecs.codec.Codec-class.html#decode_character" class="summary-sig-name">decode_character</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">pbs</span>)</span><br />
      Returns the decoded version of the next character from the input 
      string and advances the current character in the PushbackString.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="esapi.codecs.codec-pysrc.html#Codec.decode_character">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
</table>
<!-- ==================== METHOD DETAILS ==================== -->
<a name="section-MethodDetails"></a>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Method Details</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-MethodDetails"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
</table>
<a name="encode"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">encode</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">immune</span>,
        <span class="sig-arg">raw</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="esapi.codecs.codec-pysrc.html#Codec.encode">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Encode a String so that it can be safely used in a specific 
  context.</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>immune</code></strong> - @param raw the String to encode</li>
    </ul></dd>
    <dt>Returns:</dt>
        <dd>the encoded String</dd>
  </dl>
</td></tr></table>
</div>
<a name="encode_character"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">encode_character</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">immune</span>,
        <span class="sig-arg">char</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="esapi.codecs.codec-pysrc.html#Codec.encode_character">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Default implementation that should be overridden in specific 
  codecs.</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>immune</code></strong> - characters immune to encoding</li>
        <li><strong class="pname"><code>char</code></strong> - the character to encode</li>
    </ul></dd>
    <dt>Returns:</dt>
        <dd>the encoded Character</dd>
  </dl>
</td></tr></table>
</div>
<a name="decode"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">decode</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">encoded</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="esapi.codecs.codec-pysrc.html#Codec.decode">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Decode a String that was encoded using the encode method in this 
  Class</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>encoded</code></strong> - the string to decode</li>
    </ul></dd>
    <dt>Returns:</dt>
        <dd>the decoded string</dd>
  </dl>
</td></tr></table>
</div>
<a name="decode_character"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">decode_character</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">pbs</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="esapi.codecs.codec-pysrc.html#Codec.decode_character">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Returns the decoded version of the next character from the input 
  string and advances the current character in the PushbackString. If the 
  current character is not encoded, this method MUST reset the 
  PushbackString.</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>pbs</code></strong> - the PushBackString to decode a character from</li>
    </ul></dd>
    <dt>Returns:</dt>
        <dd>the decoded Character</dd>
  </dl>
</td></tr></table>
</div>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="esapi-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

      <th class="navbar" width="100%"></th>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
  <tr>
    <td align="left" class="footer">
    Generated by Epydoc 3.0.1 on Sun Nov  8 16:04:21 2009
    </td>
    <td align="right" class="footer">
      <a target="mainFrame" href="http://epydoc.sourceforge.net"
        >http://epydoc.sourceforge.net</a>
    </td>
  </tr>
</table>

<script type="text/javascript">
  <!--
  // Private objects are initially displayed (because if
  // javascript is turned off then we want them to be
  // visible); but by default, we want to hide them.  So hide
  // them unless we have a cookie that says to show them.
  checkCookie();
  // -->
</script>
</body>
</html>
